package cn.fintecher.pangolin.service.business.model.request;

import cn.fintecher.pangolin.common.enums.State;
import cn.fintecher.pangolin.entity.mysql.QComplianceCheck;
import com.querydsl.core.BooleanBuilder;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang.StringUtils;

import java.util.Objects;

/**
 * @Author wangxiangdong
 * @Description 查询request
 * @Date 2019/10/19 11:24
 **/
@Data
public class ComplianceCheckQueryRequest {

    @ApiModelProperty(value = "配置名称")
    private String configName;

    @ApiModelProperty(value = "状态")
    private State status;

    public BooleanBuilder generateBooleanBuilder(){
        BooleanBuilder booleanBuilder = new BooleanBuilder();
        if(StringUtils.isNotBlank(configName)){
            booleanBuilder.and(QComplianceCheck.complianceCheck.configName.like(org.apache.commons.lang3.StringUtils.join(configName,"%")));
        }
        if(Objects.nonNull(status)){
            booleanBuilder.and(QComplianceCheck.complianceCheck.status.eq(status));
        }
        return booleanBuilder;
    }
}
